<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>flashobject.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
  </script>

  <script src="static/js/doc.js">
  </script>

  <meta charset="utf8">
</head>

<body onload="prettyPrint()">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_ui_media_flashobject.js.html">flashobject.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line2"></a>// you may not use this file except in compliance with the License.
<a name="line3"></a>// You may obtain a copy of the License at
<a name="line4"></a>//
<a name="line5"></a>//     http://www.apache.org/licenses/LICENSE-2.0
<a name="line6"></a>//
<a name="line7"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line8"></a>// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<a name="line9"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line10"></a>// See the License for the specific language governing permissions and
<a name="line11"></a>// limitations under the License.
<a name="line12"></a>
<a name="line13"></a>// Copyright 2009 Google Inc. All Rights Reserved.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Wrapper on a Flash object embedded in the HTML page.
<a name="line17"></a> * This class contains routines for writing the HTML to create the Flash object
<a name="line18"></a> * using a goog.ui.Component approach. Tested on Firefox 1.5, 2 and 3, IE6, 7,
<a name="line19"></a> * Konqueror, Chrome and Safari.
<a name="line20"></a> *
<a name="line21"></a> * Based on http://go/flashobject.js
<a name="line22"></a> *
<a name="line23"></a> * Based on the following compatibility test suite:
<a name="line24"></a> * http://www.bobbyvandersluis.com/flashembed/testsuite/
<a name="line25"></a> *
<a name="line26"></a> * TODO: take a look at swfobject, and maybe use it instead of the current
<a name="line27"></a> * flash embedding method.
<a name="line28"></a> *
<a name="line29"></a> * Examples of usage:
<a name="line30"></a> *
<a name="line31"></a> * &lt;pre&gt;
<a name="line32"></a> *   var flash = new goog.ui.media.FlashObject(&#39;http://hostname/flash.swf&#39;);
<a name="line33"></a> *   flash.setFlashVar(&#39;myvar&#39;, &#39;foo&#39;);
<a name="line34"></a> *   flash.render(goog.dom.$(&#39;parent&#39;));
<a name="line35"></a> * &lt;/pre&gt;
<a name="line36"></a> *
<a name="line37"></a> * TODO: create a goog.ui.media.BrowserInterfaceFlashObject that
<a name="line38"></a> * subclasses goog.ui.media.FlashObject to provide all the goodness of
<a name="line39"></a> * http://go/browserinterface.as
<a name="line40"></a> *
<a name="line41"></a> */
<a name="line42"></a>
<a name="line43"></a>goog.provide(&#39;goog.ui.media.FlashObject&#39;);
<a name="line44"></a>goog.provide(&#39;goog.ui.media.FlashObject.Wmodes&#39;);
<a name="line45"></a>
<a name="line46"></a>goog.require(&#39;goog.asserts&#39;);
<a name="line47"></a>goog.require(&#39;goog.debug.Logger&#39;);
<a name="line48"></a>goog.require(&#39;goog.events.EventHandler&#39;);
<a name="line49"></a>goog.require(&#39;goog.string&#39;);
<a name="line50"></a>goog.require(&#39;goog.structs.Map&#39;);
<a name="line51"></a>goog.require(&#39;goog.style&#39;);
<a name="line52"></a>goog.require(&#39;goog.ui.Component&#39;);
<a name="line53"></a>goog.require(&#39;goog.ui.Component.Error&#39;);
<a name="line54"></a>goog.require(&#39;goog.userAgent&#39;);
<a name="line55"></a>goog.require(&#39;goog.userAgent.flash&#39;);
<a name="line56"></a>
<a name="line57"></a>
<a name="line58"></a>/**
<a name="line59"></a> * A very simple flash wrapper, that allows you to create flash object
<a name="line60"></a> * programmatically, instead of embedding your own HTML. It extends
<a name="line61"></a> * {@link goog.ui.Component}, which makes it very easy to be embedded on the
<a name="line62"></a> * page.
<a name="line63"></a> *
<a name="line64"></a> * @param {string} flashUrl The flash SWF URL.
<a name="line65"></a> * @param {goog.dom.DomHelper} opt_domHelper An optional DomHelper.
<a name="line66"></a> * @extends {goog.ui.Component}
<a name="line67"></a> * @constructor
<a name="line68"></a> */
<a name="line69"></a>goog.ui.media.FlashObject = function(flashUrl, opt_domHelper) {
<a name="line70"></a>  goog.ui.Component.call(this, opt_domHelper);
<a name="line71"></a>
<a name="line72"></a>  /**
<a name="line73"></a>   * The URL of the flash movie to be embedded.
<a name="line74"></a>   *
<a name="line75"></a>   * @type {string}
<a name="line76"></a>   * @private
<a name="line77"></a>   */
<a name="line78"></a>  this.flashUrl_ = flashUrl;
<a name="line79"></a>
<a name="line80"></a>  /**
<a name="line81"></a>   * An event handler used to handle events consistently between browsers.
<a name="line82"></a>   * @type {goog.events.EventHandler}
<a name="line83"></a>   * @private
<a name="line84"></a>   */
<a name="line85"></a>  this.eventHandler_ = new goog.events.EventHandler(this);
<a name="line86"></a>
<a name="line87"></a>  /**
<a name="line88"></a>   * A map of variables to be passed to the flash movie.
<a name="line89"></a>   *
<a name="line90"></a>   * @type {goog.structs.Map}
<a name="line91"></a>   * @private
<a name="line92"></a>   */
<a name="line93"></a>  this.flashVars_ = new goog.structs.Map();
<a name="line94"></a>};
<a name="line95"></a>goog.inherits(goog.ui.media.FlashObject, goog.ui.Component);
<a name="line96"></a>
<a name="line97"></a>
<a name="line98"></a>/**
<a name="line99"></a> * Different states of loaded-ness in which the SWF itself can be
<a name="line100"></a> *
<a name="line101"></a> * Talked about at:
<a name="line102"></a> * http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12059&amp;sliceId=1
<a name="line103"></a> *
<a name="line104"></a> * @enum {number}
<a name="line105"></a> * @private
<a name="line106"></a> */
<a name="line107"></a>goog.ui.media.FlashObject.SwfReadyStates_ = {
<a name="line108"></a>  LOADING: 0,
<a name="line109"></a>  UNINITIALIZED: 1,
<a name="line110"></a>  LOADED: 2,
<a name="line111"></a>  INTERACTIVE: 3,
<a name="line112"></a>  COMPLETE: 4
<a name="line113"></a>};
<a name="line114"></a>
<a name="line115"></a>
<a name="line116"></a>/**
<a name="line117"></a> * The different modes for displaying a SWF. Note that different wmodes
<a name="line118"></a> * can result in different bugs in different browsers and also that
<a name="line119"></a> * both OPAQUE and TRANSPARENT will result in a performance hit.
<a name="line120"></a> *
<a name="line121"></a> * @enum {string}
<a name="line122"></a> */
<a name="line123"></a>goog.ui.media.FlashObject.Wmodes = {
<a name="line124"></a>  /**
<a name="line125"></a>   * Allows for z-ordering of the SWF.
<a name="line126"></a>   */
<a name="line127"></a>  OPAQUE: &#39;opaque&#39;,
<a name="line128"></a>
<a name="line129"></a>  /**
<a name="line130"></a>   * Allows for z-ordering of the SWF and plays the swf with a transparent BG.
<a name="line131"></a>   */
<a name="line132"></a>  TRANSPARENT: &#39;transparent&#39;,
<a name="line133"></a>
<a name="line134"></a>  /**
<a name="line135"></a>   * The default wmode. Does not allow for z-ordering of the SWF.
<a name="line136"></a>   */
<a name="line137"></a>  WINDOW: &#39;window&#39;
<a name="line138"></a>};
<a name="line139"></a>
<a name="line140"></a>
<a name="line141"></a>/**
<a name="line142"></a> * The component CSS namespace.
<a name="line143"></a> *
<a name="line144"></a> * @type {string}
<a name="line145"></a> */
<a name="line146"></a>goog.ui.media.FlashObject.CSS_CLASS = goog.getCssName(&#39;goog-ui-media-flash&#39;);
<a name="line147"></a>
<a name="line148"></a>
<a name="line149"></a>/**
<a name="line150"></a> * The flash object CSS class.
<a name="line151"></a> *
<a name="line152"></a> * @type {string}
<a name="line153"></a> */
<a name="line154"></a>goog.ui.media.FlashObject.FLASH_CSS_CLASS =
<a name="line155"></a>    goog.getCssName(&#39;goog-ui-media-flash-object&#39;);
<a name="line156"></a>
<a name="line157"></a>
<a name="line158"></a>/**
<a name="line159"></a> * Template for the object tag for IE.
<a name="line160"></a> *
<a name="line161"></a> * @type {string}
<a name="line162"></a> * @private
<a name="line163"></a> */
<a name="line164"></a>goog.ui.media.FlashObject.IE_HTML_ =
<a name="line165"></a>    &#39;&lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot;&#39; +
<a name="line166"></a>           &#39; id=&quot;%s&quot;&#39; +
<a name="line167"></a>           &#39; name=&quot;%s&quot;&#39; +
<a name="line168"></a>           &#39; class=&quot;%s&quot;&#39; +
<a name="line169"></a>           &#39;&gt;&#39; +
<a name="line170"></a>      &#39;&lt;param name=&quot;movie&quot; value=&quot;%s&quot;/&gt;&#39; +
<a name="line171"></a>      &#39;&lt;param name=&quot;quality&quot; value=&quot;high&quot;/&gt;&#39; +
<a name="line172"></a>      &#39;&lt;param name=&quot;FlashVars&quot; value=&quot;%s&quot;/&gt;&#39; +
<a name="line173"></a>      &#39;&lt;param name=&quot;bgcolor&quot; value=&quot;%s&quot;/&gt;&#39; +
<a name="line174"></a>      &#39;&lt;param name=&quot;AllowScriptAccess&quot; value=&quot;sameDomain&quot;/&gt;&#39; +
<a name="line175"></a>      &#39;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;/&gt;&#39; +
<a name="line176"></a>      &#39;&lt;param name=&quot;SeamlessTabbing&quot; value=&quot;false&quot;/&gt;&#39; +
<a name="line177"></a>      &#39;%s&#39; +
<a name="line178"></a>    &#39;&lt;/object&gt;&#39;;
<a name="line179"></a>
<a name="line180"></a>
<a name="line181"></a>/**
<a name="line182"></a> * Template for the wmode param for IE.
<a name="line183"></a> *
<a name="line184"></a> * @type {string}
<a name="line185"></a> * @private
<a name="line186"></a> */
<a name="line187"></a>goog.ui.media.FlashObject.IE_WMODE_PARAMS_ = &#39;&lt;param name=&quot;wmode&quot; value=&quot;%s&quot;/&gt;&#39;;
<a name="line188"></a>
<a name="line189"></a>
<a name="line190"></a>/**
<a name="line191"></a> * Template for the embed tag for FF.
<a name="line192"></a> *
<a name="line193"></a> * @type {string}
<a name="line194"></a> * @private
<a name="line195"></a> */
<a name="line196"></a>goog.ui.media.FlashObject.FF_HTML_ =
<a name="line197"></a>    &#39;&lt;embed quality=&quot;high&quot;&#39; +
<a name="line198"></a>          &#39; id=&quot;%s&quot;&#39; +
<a name="line199"></a>          &#39; name=&quot;%s&quot;&#39; +
<a name="line200"></a>          &#39; class=&quot;%s&quot;&#39; +
<a name="line201"></a>          &#39; src=&quot;%s&quot;&#39; +
<a name="line202"></a>          &#39; FlashVars=&quot;%s&quot;&#39; +
<a name="line203"></a>          &#39; bgcolor=&quot;%s&quot;&#39; +
<a name="line204"></a>          &#39; AllowScriptAccess=&quot;sameDomain&quot;&#39; +
<a name="line205"></a>          &#39; allowFullScreen=&quot;true&quot;&#39; +
<a name="line206"></a>          &#39; SeamlessTabbing=&quot;false&quot;&#39; +
<a name="line207"></a>          &#39; type=&quot;application/x-shockwave-flash&quot;&#39; +
<a name="line208"></a>          &#39; pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot;&#39; +
<a name="line209"></a>          &#39; %s&gt;&#39; +
<a name="line210"></a>    &#39;&lt;/embed&gt;&#39;;
<a name="line211"></a>
<a name="line212"></a>
<a name="line213"></a>/**
<a name="line214"></a> * Template for the wmode param for Firefox.
<a name="line215"></a> *
<a name="line216"></a> * @type {string}
<a name="line217"></a> * @private
<a name="line218"></a> */
<a name="line219"></a>goog.ui.media.FlashObject.FF_WMODE_PARAMS_ = &#39;wmode=%s&#39;;
<a name="line220"></a>
<a name="line221"></a>
<a name="line222"></a>/**
<a name="line223"></a> * A logger used for debugging.
<a name="line224"></a> *
<a name="line225"></a> * @type {goog.debug.Logger}
<a name="line226"></a> * @private
<a name="line227"></a> */
<a name="line228"></a>goog.ui.media.FlashObject.prototype.logger_ =
<a name="line229"></a>    goog.debug.Logger.getLogger(&#39;goog.ui.media.FlashObject&#39;);
<a name="line230"></a>
<a name="line231"></a>
<a name="line232"></a>/**
<a name="line233"></a> * The wmode for the SWF.
<a name="line234"></a> *
<a name="line235"></a> * @type {goog.ui.media.FlashObject.Wmodes}
<a name="line236"></a> * @private
<a name="line237"></a> */
<a name="line238"></a>goog.ui.media.FlashObject.prototype.wmode_ =
<a name="line239"></a>    goog.ui.media.FlashObject.Wmodes.WINDOW;
<a name="line240"></a>
<a name="line241"></a>
<a name="line242"></a>/**
<a name="line243"></a> * The minimum required flash version.
<a name="line244"></a> *
<a name="line245"></a> * @type {?string}
<a name="line246"></a> * @private
<a name="line247"></a> */
<a name="line248"></a>goog.ui.media.FlashObject.prototype.requiredVersion_;
<a name="line249"></a>
<a name="line250"></a>
<a name="line251"></a>/**
<a name="line252"></a> * The flash movie width.
<a name="line253"></a> *
<a name="line254"></a> * @type {string}
<a name="line255"></a> * @private
<a name="line256"></a> */
<a name="line257"></a>goog.ui.media.FlashObject.prototype.width_;
<a name="line258"></a>
<a name="line259"></a>
<a name="line260"></a>/**
<a name="line261"></a> * The flash movie height.
<a name="line262"></a> *
<a name="line263"></a> * @type {string}
<a name="line264"></a> * @private
<a name="line265"></a> */
<a name="line266"></a>goog.ui.media.FlashObject.prototype.height_;
<a name="line267"></a>
<a name="line268"></a>
<a name="line269"></a>/**
<a name="line270"></a> * The flash movie background color.
<a name="line271"></a> *
<a name="line272"></a> * @type {string}
<a name="line273"></a> * @private
<a name="line274"></a> */
<a name="line275"></a>goog.ui.media.FlashObject.prototype.backgroundColor_ = &#39;#000000&#39;;
<a name="line276"></a>
<a name="line277"></a>
<a name="line278"></a>/**
<a name="line279"></a> * Sets the flash movie Wmode.
<a name="line280"></a> *
<a name="line281"></a> * @param {goog.ui.media.FlashObject.Wmodes} wmode the flash movie Wmode.
<a name="line282"></a> * @return {goog.ui.media.FlashObject} The flash object instance for chaining.
<a name="line283"></a> */
<a name="line284"></a>goog.ui.media.FlashObject.prototype.setWmode = function(wmode) {
<a name="line285"></a>  this.wmode_ = wmode;
<a name="line286"></a>  return this;
<a name="line287"></a>};
<a name="line288"></a>
<a name="line289"></a>
<a name="line290"></a>/**
<a name="line291"></a> * @return {string} Returns the flash movie wmode.
<a name="line292"></a> */
<a name="line293"></a>goog.ui.media.FlashObject.prototype.getWmode = function() {
<a name="line294"></a>  return this.wmode_;
<a name="line295"></a>};
<a name="line296"></a>
<a name="line297"></a>
<a name="line298"></a>/**
<a name="line299"></a> * Adds flash variables.
<a name="line300"></a> *
<a name="line301"></a> * @param {goog.structs.Map|Object} map A key-value map of variables.
<a name="line302"></a> * @return {goog.ui.media.FlashObject} The flash object instance for chaining.
<a name="line303"></a> */
<a name="line304"></a>goog.ui.media.FlashObject.prototype.addFlashVars = function(map) {
<a name="line305"></a>  this.flashVars_.addAll(map);
<a name="line306"></a>  return this;
<a name="line307"></a>};
<a name="line308"></a>
<a name="line309"></a>
<a name="line310"></a>/**
<a name="line311"></a> * Sets a flash variable.
<a name="line312"></a> *
<a name="line313"></a> * @param {string} key The name of the flash variable.
<a name="line314"></a> * @param {string} value The value of the flash variable.
<a name="line315"></a> * @return {goog.ui.media.FlashObject} The flash object instance for chaining.
<a name="line316"></a> */
<a name="line317"></a>goog.ui.media.FlashObject.prototype.setFlashVar = function(key, value) {
<a name="line318"></a>  this.flashVars_.set(key, value);
<a name="line319"></a>  return this;
<a name="line320"></a>};
<a name="line321"></a>
<a name="line322"></a>
<a name="line323"></a>/**
<a name="line324"></a> * Sets flash variables. You can either pass a Map of key-&gt;value pairs or you
<a name="line325"></a> * can pass a key, value pair to set a specific variable.
<a name="line326"></a> *
<a name="line327"></a> * TODO: Get rid of this method.
<a name="line328"></a> *
<a name="line329"></a> * @deprecated Use {@link #addFlashVars} or {@link #setFlashVar} instead.
<a name="line330"></a> * @param {goog.structs.Map|Object|string} flashVar A map of variables (given
<a name="line331"></a> *    as a goog.structs.Map or an Object literal) or a key to the optional
<a name="line332"></a> *    {@code opt_value}.
<a name="line333"></a> * @param {string} opt_value The optional value for the flashVar key.
<a name="line334"></a> * @return {goog.ui.media.FlashObject} The flash object instance for chaining.
<a name="line335"></a> */
<a name="line336"></a>goog.ui.media.FlashObject.prototype.setFlashVars = function(flashVar,
<a name="line337"></a>                                                            opt_value) {
<a name="line338"></a>  if (flashVar instanceof goog.structs.Map ||
<a name="line339"></a>      goog.typeOf(flashVar) == &#39;object&#39;) {
<a name="line340"></a>    this.addFlashVars(flashVar);
<a name="line341"></a>  } else {
<a name="line342"></a>    goog.asserts.assert(goog.isString(flashVar) &amp;&amp; goog.isDef(opt_value),
<a name="line343"></a>        &#39;Invalid argument(s)&#39;);
<a name="line344"></a>    this.setFlashVar(String(flashVar), String(opt_value));
<a name="line345"></a>  }
<a name="line346"></a>  return this;
<a name="line347"></a>};
<a name="line348"></a>
<a name="line349"></a>
<a name="line350"></a>/**
<a name="line351"></a> * @return {goog.structs.Map} The current flash variables.
<a name="line352"></a> */
<a name="line353"></a>goog.ui.media.FlashObject.prototype.getFlashVars = function() {
<a name="line354"></a>  return this.flashVars_;
<a name="line355"></a>};
<a name="line356"></a>
<a name="line357"></a>
<a name="line358"></a>/**
<a name="line359"></a> * Sets the background color of the movie.
<a name="line360"></a> *
<a name="line361"></a> * @param {string} color The new color to be set.
<a name="line362"></a> * @return {goog.ui.media.FlashObject} The flash object instance for chaining.
<a name="line363"></a> */
<a name="line364"></a>goog.ui.media.FlashObject.prototype.setBackgroundColor = function(color) {
<a name="line365"></a>  this.backgroundColor_ = color;
<a name="line366"></a>  return this;
<a name="line367"></a>};
<a name="line368"></a>
<a name="line369"></a>
<a name="line370"></a>/**
<a name="line371"></a> * @return {string} The background color of the movie.
<a name="line372"></a> */
<a name="line373"></a>goog.ui.media.FlashObject.prototype.getBackgroundColor = function() {
<a name="line374"></a>  return this.backgroundColor_;
<a name="line375"></a>};
<a name="line376"></a>
<a name="line377"></a>
<a name="line378"></a>/**
<a name="line379"></a> * Sets the width and height of the movie.
<a name="line380"></a> *
<a name="line381"></a> * @param {number|string} width The width of the movie.
<a name="line382"></a> * @param {number|string} height The height of the movie.
<a name="line383"></a> * @return {goog.ui.media.FlashObject} The flash object instance for chaining.
<a name="line384"></a> */
<a name="line385"></a>goog.ui.media.FlashObject.prototype.setSize = function(width, height) {
<a name="line386"></a>  this.width_ = goog.isString(width) ? width : Math.round(width) + &#39;px&#39;;
<a name="line387"></a>  this.height_ = goog.isString(height) ? height : Math.round(height) + &#39;px&#39;;
<a name="line388"></a>  if (this.getElement()) {
<a name="line389"></a>    goog.style.setSize(this.getFlashElement(), this.width_, this.height_);
<a name="line390"></a>  }
<a name="line391"></a>  return this;
<a name="line392"></a>};
<a name="line393"></a>
<a name="line394"></a>
<a name="line395"></a>/**
<a name="line396"></a> * @return {?string} The flash required version.
<a name="line397"></a> */
<a name="line398"></a>goog.ui.media.FlashObject.prototype.getRequiredVersion = function() {
<a name="line399"></a>  return this.requiredVersion_;
<a name="line400"></a>};
<a name="line401"></a>
<a name="line402"></a>
<a name="line403"></a>/**
<a name="line404"></a> * Sets the minimum flash required version.
<a name="line405"></a> *
<a name="line406"></a> * @param {?string} version The minimum required version for this movie to work,
<a name="line407"></a> *     or null if you want to unset it.
<a name="line408"></a> * @return {goog.ui.media.FlashObject} The flash object instance for chaining.
<a name="line409"></a> */
<a name="line410"></a>goog.ui.media.FlashObject.prototype.setRequiredVersion = function(version) {
<a name="line411"></a>  this.requiredVersion_ = version;
<a name="line412"></a>  return this;
<a name="line413"></a>};
<a name="line414"></a>
<a name="line415"></a>
<a name="line416"></a>/**
<a name="line417"></a> * Returns whether this SWF has a minimum required flash version.
<a name="line418"></a> *
<a name="line419"></a> * @return {boolean} Whether a required version was set or not.
<a name="line420"></a> */
<a name="line421"></a>goog.ui.media.FlashObject.prototype.hasRequiredVersion = function() {
<a name="line422"></a>  return this.requiredVersion_ != null;
<a name="line423"></a>};
<a name="line424"></a>
<a name="line425"></a>
<a name="line426"></a>/**
<a name="line427"></a> * On {@code enterDocument}, listen for all events to handle them consistently.
<a name="line428"></a> * @inheritDoc
<a name="line429"></a> */
<a name="line430"></a>goog.ui.media.FlashObject.prototype.enterDocument = function() {
<a name="line431"></a>  goog.ui.media.FlashObject.superClass_.enterDocument.call(this);
<a name="line432"></a>  this.eventHandler_.listen(
<a name="line433"></a>      this.getElement(),
<a name="line434"></a>      goog.object.getValues(goog.events.EventType),
<a name="line435"></a>      this.onAnyEvent_);
<a name="line436"></a>};
<a name="line437"></a>
<a name="line438"></a>
<a name="line439"></a>/**
<a name="line440"></a> * Sinks all the events on the bubble phase.
<a name="line441"></a> *
<a name="line442"></a> * Flash plugins propagates events from/to the plugin to the browser
<a name="line443"></a> * inconsistently:
<a name="line444"></a> *
<a name="line445"></a> * 1) FF2 + linux: the flash plugin will stop the propagation of all events from
<a name="line446"></a> * the plugin to the browser.
<a name="line447"></a> * 2) FF3 + mac: the flash plugin will propagate events on the &lt;embed&gt; object
<a name="line448"></a> * but that will get propagated to its parents.
<a name="line449"></a> * 3) Safari 3.1.1 + mac: the flash plugin will propagate the event to the
<a name="line450"></a> * &lt;object&gt; tag that event will propagate to its parents.
<a name="line451"></a> * 4) IE7 + windows: the flash plugin  will eat all events, not propagating
<a name="line452"></a> * anything to the javascript.
<a name="line453"></a> * 5) Chrome + windows: the flash plugin will eat all events, not propagating
<a name="line454"></a> * anything to the javascript.
<a name="line455"></a> *
<a name="line456"></a> * To overcome this inconsistency, all events from/to the plugin are sinked,
<a name="line457"></a> * since you can&#39;t assume that the events will be propagated.
<a name="line458"></a> *
<a name="line459"></a> * NOTE: we only sink events on the bubbling phase, since there are no
<a name="line460"></a> * inexpensive/scalable way to stop events on the capturing phase unless we
<a name="line461"></a> * added an event listener on the document for each flash object.
<a name="line462"></a> *
<a name="line463"></a> * @param {goog.events.Event} e The event to be stopped.
<a name="line464"></a> * @private
<a name="line465"></a> */
<a name="line466"></a>goog.ui.media.FlashObject.prototype.onAnyEvent_ = function(e) {
<a name="line467"></a>  e.stopPropagation();
<a name="line468"></a>};
<a name="line469"></a>
<a name="line470"></a>
<a name="line471"></a>/**
<a name="line472"></a> * Creates the DOM structure.
<a name="line473"></a> *
<a name="line474"></a> * @inheritDoc
<a name="line475"></a> */
<a name="line476"></a>goog.ui.media.FlashObject.prototype.createDom = function() {
<a name="line477"></a>  if (this.hasRequiredVersion() &amp;&amp;
<a name="line478"></a>      !goog.userAgent.flash.isVersion(
<a name="line479"></a>          /** @type {string} */ (this.getRequiredVersion()))) {
<a name="line480"></a>    this.logger_.warning(&#39;Required flash version not found:&#39; +
<a name="line481"></a>        this.getRequiredVersion());
<a name="line482"></a>    throw Error(goog.ui.Component.Error.NOT_SUPPORTED);
<a name="line483"></a>  }
<a name="line484"></a>
<a name="line485"></a>  var element = this.getDomHelper().createElement(&#39;div&#39;);
<a name="line486"></a>  element.className = goog.ui.media.FlashObject.CSS_CLASS;
<a name="line487"></a>  element.innerHTML = this.generateSwfTag_();
<a name="line488"></a>  this.setElementInternal(element);
<a name="line489"></a>
<a name="line490"></a>  if (this.width_ &amp;&amp; this.height_) {
<a name="line491"></a>    this.setSize(this.width_, this.height_);
<a name="line492"></a>  }
<a name="line493"></a>};
<a name="line494"></a>
<a name="line495"></a>
<a name="line496"></a>/**
<a name="line497"></a> * Writes the HTML to embed the flash object.
<a name="line498"></a> *
<a name="line499"></a> * @return {string} Browser appropriate HTML to add the SWF to the DOM.
<a name="line500"></a> * @private
<a name="line501"></a> */
<a name="line502"></a>goog.ui.media.FlashObject.prototype.generateSwfTag_ = function() {
<a name="line503"></a>  var template = goog.userAgent.IE ? goog.ui.media.FlashObject.IE_HTML_ :
<a name="line504"></a>      goog.ui.media.FlashObject.FF_HTML_;
<a name="line505"></a>
<a name="line506"></a>  var params = goog.userAgent.IE ? goog.ui.media.FlashObject.IE_WMODE_PARAMS_ :
<a name="line507"></a>      goog.ui.media.FlashObject.FF_WMODE_PARAMS_;
<a name="line508"></a>
<a name="line509"></a>  params = goog.string.subs(params, this.wmode_);
<a name="line510"></a>
<a name="line511"></a>  var keys = this.flashVars_.getKeys();
<a name="line512"></a>  var values = this.flashVars_.getValues();
<a name="line513"></a>
<a name="line514"></a>  var flashVars = [];
<a name="line515"></a>  for (var i = 0; i &lt; keys.length; i++) {
<a name="line516"></a>    var key = goog.string.urlEncode(keys[i]);
<a name="line517"></a>    var value = goog.string.urlEncode(values[i]);
<a name="line518"></a>    flashVars.push(key + &#39;=&#39; + value);
<a name="line519"></a>  }
<a name="line520"></a>
<a name="line521"></a>  // TODO: find a more efficient way to build the HTML.
<a name="line522"></a>  return goog.string.subs(
<a name="line523"></a>      template,
<a name="line524"></a>      this.getId(),
<a name="line525"></a>      this.getId(),
<a name="line526"></a>      goog.ui.media.FlashObject.FLASH_CSS_CLASS,
<a name="line527"></a>      goog.string.htmlEscape(this.flashUrl_),
<a name="line528"></a>      goog.string.htmlEscape(flashVars.join(&#39;&amp;&#39;)),
<a name="line529"></a>      this.backgroundColor_,
<a name="line530"></a>      params);
<a name="line531"></a>};
<a name="line532"></a>
<a name="line533"></a>
<a name="line534"></a>/**
<a name="line535"></a> * @return {Element} The flash element.
<a name="line536"></a> */
<a name="line537"></a>goog.ui.media.FlashObject.prototype.getFlashElement = function() {
<a name="line538"></a>  return /** @type {Element} */ this.getElement().firstChild;
<a name="line539"></a>};
<a name="line540"></a>
<a name="line541"></a>
<a name="line542"></a>/** @inheritDoc */
<a name="line543"></a>goog.ui.media.FlashObject.prototype.disposeInternal = function() {
<a name="line544"></a>  goog.ui.media.FlashObject.superClass_.disposeInternal.call(this);
<a name="line545"></a>  this.flashVars_ = null;
<a name="line546"></a>
<a name="line547"></a>  this.eventHandler_.dispose();
<a name="line548"></a>  this.eventHandler_ = null;
<a name="line549"></a>};
<a name="line550"></a>
<a name="line551"></a>
<a name="line552"></a>/**
<a name="line553"></a> * @return {boolean} whether the SWF has finished loading or not.
<a name="line554"></a> */
<a name="line555"></a>goog.ui.media.FlashObject.prototype.isLoaded = function() {
<a name="line556"></a>  if (!this.isInDocument() || !this.getElement()) {
<a name="line557"></a>    return false;
<a name="line558"></a>  }
<a name="line559"></a>
<a name="line560"></a>  if (this.getFlashElement().readyState &amp;&amp;
<a name="line561"></a>      this.getFlashElement().readyState ==
<a name="line562"></a>          goog.ui.media.FlashObject.SwfReadyStates_.COMPLETE) {
<a name="line563"></a>    return true;
<a name="line564"></a>  }
<a name="line565"></a>
<a name="line566"></a>  if (this.getFlashElement().PercentLoaded &amp;&amp;
<a name="line567"></a>      this.getFlashElement().PercentLoaded() == 100) {
<a name="line568"></a>    return true;
<a name="line569"></a>  }
<a name="line570"></a>
<a name="line571"></a>  return false;
<a name="line572"></a>};
</pre>


</body>
</html>
